package com.example.vueadmin.mapper;

import com.example.vueadmin.entity.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;


import java.util.List;

@Mapper
public interface CategoryMapper {

    List<Category> all();

    List<Category> children(Integer id);

    @Insert("INSERT into `category` (parent_id,name,sort,create_time) VALUES (#{parentId},#{name},#{sort},#{createTime})")
    Integer add(Category category);

    @Delete("Delete from `category` where id = #{id}")
    Integer delete(Integer id);

    Integer deleteAll(Integer[] ids);

    @Update("update `category` set parent_id = #{parentId},name=#{name},sort=#{sort},update_time=#{updateTime} where id = #{id}")
    Integer update(Category category);
}
